Skip to content

refactor(codegen): migrate array-allocator to typeof() (phase-e step 5, pr2)#575

Merged
cs01 merged 1 commit intomainfrom
refactor/typeof-array-allocator
Apr 20, 2026
Merged

refactor(codegen): migrate array-allocator to typeof() (phase-e step 5, pr2)#575
cs01 merged 1 commit intomainfrom
refactor/typeof-array-allocator

Conversation

@cs01
Copy link
Copy Markdown
Owner

@cs01 cs01 commented Apr 20, 2026

Why this matters for users

Part of Phase E's type-resolver consolidation. Each migrated site is one less place where two codegen paths can disagree about an expression's type and silently produce wrong native code. No user-visible behavior change in this PR — it's a mechanical swap that routes a query through the annotator's pre-populated cache.

Change

ArrayAllocator.buildInterfaceElementInfo formerly called ctx.resolveExpressionTypeRich(expr) directly. Now calls ctx.typeOf(expr) — same semantics (returns ResolvedType | null), but hits the annotator cache first, only falling through to resolveExpressionTypeRich for expressions the annotator skipped (unknown-base).

Interface ArrayAllocatorContext updated accordingly.

Verification

Full npm run verify (tests + stage 2 self-host) green locally.

Scope

One call site. First consumer migration following the Step-5 annotator landing in #573. More migrations land in subsequent PRs.

@github-actions
Copy link
Copy Markdown
Contributor

Benchmark Results (Linux x86-64)

Benchmark C ChadScript Go Node Place
Binary Trees 1.644s 1.377s 2.762s 1.269s 🥈
Cold Start 1.0ms 0.8ms 1.3ms 30.2ms 🥇
Fibonacci 0.814s 0.766s 1.564s 3.173s 🥇
File I/O 0.119s 0.092s 0.090s 0.209s 🥈
JSON Parse/Stringify 0.004s 0.005s 0.017s 0.017s 🥈
Matrix Multiply 0.435s 1.005s 0.566s 0.358s #4
Monte Carlo Pi 0.389s 0.410s 0.405s 2.249s 🥉
N-Body Simulation 1.667s 2.119s 2.210s 2.390s 🥈
Quicksort 0.215s 0.247s 0.214s 0.262s 🥉
SQLite 0.349s 0.368s 0.469s 🥈
Sieve of Eratosthenes 0.013s 0.028s 0.020s 0.038s 🥉
String Manipulation 0.008s 0.019s 0.016s 0.037s 🥉

CLI Tool Benchmarks

Benchmark ChadScript grep node xxd Place
Hex Dump 0.563s 1.033s 0.129s 🥈
Recursive Grep 0.021s 0.011s 0.107s 🥈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant